using System;
using System.Collections.Generic;
using System.Text;

using LogAnalyzerIIS.Helpers;

namespace LogAnalyzerIIS.Objects
{
	/// <summary>
	/// Structure for storing cell data from xlsx-file
	/// </summary>
	public struct ExcelCell
	{
		// Name of column  this cell belongs to (i.e. "Name1", "Name2", "Name3", etc)
		private string columnName;

		// Position name of column  this cell belongs to (i.e. "A", "B", "C", etc.)
		private string columnPosition;

		// Value of data cell
		private string cellValue;

		/// <summary>
		/// Constructor of ExcelCell structure
		/// </summary>
		/// <param name="name">Name of column this cell belongs to</param>
		/// <param name="colname">Position name of the column this cell belongs to</param>
		public ExcelCell(string name, string cellPosition)
		{
			columnName = name;

			columnPosition = ExcelHelper.GetColumnPosition(cellPosition);

			cellValue = "";
		}

		/// <summary>
		/// Returns the name of the column this cell belongs to
		/// </summary>
		public string Name
		{
			get { return columnName; }
		}

		/// <summary>
		/// Returns the position name of the column this cell belongs to
		/// </summary>
		public string ColumnName
		{
			get { return columnPosition; }
		}

		/// <summary>
		/// Returns a value of this cell
		/// </summary>
		public string CellValue
		{
			get { return cellValue; }
			set
			{
				if (value == "")
					cellValue = "null";
				else
					cellValue = value;
			}
		}

		/// <summary>
		/// Overridden version of Object.ToString()
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return columnName;
		}
	}
}
